package qj.pooling;

import qj.concurrent.LazyWorker;
import qj.pooling.PoolManagable;
import qj.pooling.SimpleObjectPool;
import qj.util.BufferUtil;

/**
 * A byte array pool.
 * <br>
 * Default array length is 8192.
 * <br>
 * 8192 is default because at this size, using pool will boost 5x the speed of 
 * acquiring up compare to normal new byte[].
 * Lower than this value, the speed is not improved or can be slower.
 * <br>
 * Created by QuanLA<br>
 * Date: Apr 1, 2006<br>
 * Time: 11:37:00 AM<br>
 */
public class BufferPool extends SimpleObjectPool implements PoolManagable {

    public BufferPool() {
        super(LazyWorker.getInstance());
        this.setPoolManager(this);
    }

    public Object createNew() {
        return new byte[BufferUtil.REASONABLE_BUFFER_SIZE]; 	
    }

    public boolean bath(Object obj) {
        return true;
    }

    public boolean prepare(Object obj) {
        return true;
    }

    public void destroy(Object obj) {
    }
}
